package logic;

import java.util.Calendar;
import java.util.Date;

public class DatePassChecker implements PassChecker{
	private MetroCardDateLimit card;
        private CardDataBase cardDataBase;
	
	public DatePassChecker( MetroCardDateLimit metroCard, CardDataBase cardDb){
            card = metroCard;
            cardDataBase = cardDb;
	}
	
	@Override
	public boolean checkPass() {
            Calendar calendar = Calendar.getInstance();
            Date currentDate = calendar.getTime();
            if ( cardDataBase.findCard(card)){
                if ( !card.getExpirationDate().after(currentDate)){
                    return true;
                }  
            }
            return false;
	}

}
